import { post, text } from '@/common/request';
import { requestParams, urlApiClientContent, urlPublicContent } from '../../services/ServerService';

const url = urlApiClientContent + 'stuFuncItem/';
const personalCenterUrl = urlApiClientContent + 'personalCenter/';
const rightsUrl= urlApiClientContent + 'rights/';
// 新增题库科目
export function saveSubject({ name ,id=""}) {
    return post(url + requestParams('saveSubject', { name,id }), null);
}

// 查询我的题库
export function pageSubject({ queryKey, pageNo, pageSize,status="" }) {
    return post(url + requestParams('pageSubject', { queryKey, pageNo, pageSize ,status}), null);
}
// 恢复题库
export function restore(subjectUuid) {
    return post(url + requestParams('restore', { subjectUuid}), null);
}
// 查询题库当前状态
export function getSubjectStatus({subjectUuid }) {
    return post(url + requestParams('getSubjectStatus', {subjectUuid}), null);
}
// getSubjectStatus
// 置顶题库
export function toTop({subjectUuid }) {
    return post(url + requestParams('toTop', {subjectUuid }), null);
}
// 删除题库
export function delSubject({ subjectUuid }) {
    return post(url + requestParams('delSubject', { subjectUuid }), null);
}
// 查询某科目的第一个知识结构id
export function getFirstStruct({ subjectUuid }) {
    return post(url + requestParams('getFirstStruct', { subjectUuid }), null);
}
// 查询知识结构
export function listStruct({ subjectUuid,queryKey=""}) {
    return post(url + requestParams('listStruct', { subjectUuid,queryKey}), null);
}
// 保存一个知识结构
export function saveStruct({ subjectUuid, parentId, name ,id=""}) {
    return post(url + requestParams('saveStruct', { subjectUuid, parentId, name,id }), null);
}

// 删除知识机构
export function delStruct({ structId}) {
    return post(url + requestParams('delStruct', { structId }), null);
}


// 单个保存试题
export function saveTheoryItem(jsonTheory) {
    return text(url + requestParams('saveTheoryItem', {}), jsonTheory);
}

// 批量保存试题
export function batchSaveTheoryItem({subjectUuid,structId,difficulty,content}) {
    return text(url + requestParams('batchSaveTheoryItem', {subjectUuid,structId,difficulty}), content);
}

// Excel导入
export function importStructTheoryItem({ subjectUuid, base64 }) {
    return text(url + requestParams('importStructTheoryItem', { subjectUuid }), base64);
}

// Word导入
export function importStructTheoryWord({ subjectUuid, base64 }) {
    return text(url + requestParams('importStructTheoryWord', { subjectUuid }), base64);
}

// 人工导题-上传文件
export function importStructTheoryArtificialFile({ subjectUuid, remark, fileName, base64,organId="",itemNum,payType }) {
    return text(url + requestParams('importStructTheoryArtificialFile', { subjectUuid, remark, fileName ,organId,itemNum,payType}), base64,true);
}

// 人工导题-查询列表
export function listArtificialFile(subjectUuid) {
    return post(url + requestParams('listArtificialFile', { subjectUuid }), null);
}

// 人工导题-查看反馈
export function listArtificialFeed({ artificialFileUuid, queryKey }) {
    return post(url + requestParams('listArtificialFeed', { artificialFileUuid, queryKey }), null);
}

// 人工导题-新增反馈
export function newArtificialFeed({ artificialFileUuid, remark }) {
    return post(url + requestParams('newArtificialFeed', { artificialFileUuid, remark }), null);
}
// 人工导题-试题确认
export function aiDocumentConfim({ aiUuid,payType="",organId=""}) {
    return post(url + requestParams('aiDocumentConfim', { aiUuid,payType,organId}), null);
}
// 试题确认
export function storeArtificial({artificialFileUuid }) {
    return post(url + requestParams('storeArtificial', { artificialFileUuid, }), null);
}

// ai 导题
export function aiUploadDocument({ subjectUuid, fileName,json}) {
    return text(url + requestParams('aiUploadDocument', { subjectUuid, fileName}),JSON.stringify(json),true );
}



// 查询ai列表
export function listFuncItemTaskAi({ subjectUuid }) {
    return post(url + requestParams('listFuncItemTaskAi', { subjectUuid }), null);
}


// 查询试题-题型
export function itemTypes({ subjectUuid }) {
    return post(url + requestParams('itemTypes', { subjectUuid }), null);
}


// 查询试题
export function pageItem({ subjectUuid,type,queryKey,pageNo,pageSize }) {
    return post(url + requestParams('pageItem', { subjectUuid,type,queryKey,pageNo,pageSize }), null);
}


// 查询试题详情
export function getTheoryItemByUuid({ uuid }) {
    return post(url + requestParams('getTheoryItemByUuid', { uuid }), null);
}

// 删除试题
export function delTheoryItem({ idStr }) {
    return post(url + requestParams('delTheoryItem', { idStr }), null);
}


// 查询所属机构
export function getOrganList() {
    return post(personalCenterUrl + requestParams('getOrganList', {  }), null);
}

// 兑换明细
export function exchangeInfo({organId="",quantity="",rightsType=""}) {
    return post(rightsUrl + requestParams('exchangeInfo', { organId,quantity,rightsType }), null);
}

// 新增权益 rights/add?   
/**
     * @param rightsType 权益类型 1:ai生成，2人工导题，3人脸识别
     * @param organId 机构
     * @param quantity 数量
     * @param modelType 模式类型   1固定  2阶梯
     * @param payType 支付方式 1余额  2积分
     * @param price 前端传递的数值
 */
export function rightsAdd({rightsType,organId="",quantity="",payType}) {
    return post(rightsUrl + requestParams('add', {rightsType, organId,quantity,payType }), null);
}